<template>
	<view class="box">
		<uNavbar title="通证地址" bgColor="transparent"></uNavbar>
		<view class="title">
			<!-- 请输入您的实名信息 -->
		</view>
		<view class="main_item" v-if="show">
			<view class="main_item_title">
				通证地址
			</view>
			<textarea class="ipt" :maxlength="100"  :value="add" placeholder="请输入通证地址" @input="getadd"/>
		</view>
		<view class="main_item" v-if="!show">
			<view class="main_item_title">
				通证地址
			</view>
			<view class="main_wrap" style="color: #A6A5AF;">
				{{add}}
				<view class="btn_change" @click="show=true">
					修改
				</view>
			</view>
		</view>
		<view class="main_item">
			<view class="main_item_title">
				手机验证码
			</view>
		</view>
		<view class="binding flex_dq" style="margin-top: 30px;">
			<u-input placeholder="请输入验证码" maxlength="6" v-model.trim="validateCode">
				<template slot="suffix">
					<u-code ref="uCode" @change="codeChange" seconds="60" changeText="X秒重新获取"></u-code>
					<u-button @tap="getCode" :text="tips" type="success" size="mini"></u-button>
				</template>
			</u-input>
		</view>


		<view class="btn" @click="getaddress">
			确定
		</view>
	</view>
</template>

<script>
	import {
		sendSms
	} from "../../api/login.js";
	import {address} from "../../api/setting.js";
	import {getuserinfo} from "../../api/index.js";
	export default {
		data() {
			return {

				validateCode: "",
				tips: '',
				add: "",
				show:false,
				info:{}
			}
		},
		onLoad() {
			this.getuser()
		},
		methods: {
			getuser(){
				getuserinfo().then(res=>{
					this.add=res.data.gs_wallet_address
					this.phone=res.data.phone
					console.log(this.add,this.phone)
				})
			},
			getaddress(){
				if(!this.add){
					uni.$u.toast("不能为空")
				}else{
					address({
						gs_wallet_address:this.add,
						sms_code:this.validateCode
					}).then(res=>{
							if(res.code==1){
								setTimeout(()=>{
									uni.navigateBack()
								},1500)
							}
							uni.$u.toast(res.msg)
					})
				}

			},

			getadd(e) {
				this.add = e.detail.value
			},

			codeChange(text) {
				this.tips = text;
			},
			getCode() {
				console.log(11111);
				let that = this;
				let data = {
					phone: that.phone,
					scene: 'wallet',
				}
				sendSms(data).then(res => {
					console.log(res);
					if (res.code == 1) {
						// that.validateCode=res.data
						uni.$u.toast(res.msg);
						if (that.$refs.uCode.canGetCode) {
							that.$refs.uCode.start();
						}
					}
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.box {
		width: 750rpx;
		height: 100vh;
		background-color: #211E38;
	}

	.title {
		width: 700rpx;
		margin-top: 40rpx;
		font-weight: 400;
		font-size: 32rpx;
		color: #FFFFFF;
		margin-left: 50rpx;
	}

	.main_item {
		width: 750rpx;

		.main_item_title {
			font-weight: 400;
			font-size: 30rpx;
			color: #FFFFFF;
			margin-left: 50rpx;
			margin-top: 40rpx;
		}

		.ipt {
			margin: 0 auto;
			margin-top: 20rpx;
			width: 630rpx;
			height: 208rpx;
			background: #342857;
			border-radius: 12rpx 12rpx 12rpx 12rpx;
			font-weight: 400;
			font-size: 32rpx;
			padding: 20rpx;
			color: #FFF;
		}

		.main_wrap {
			overflow: hidden;
			margin: 0 auto;
			margin-top: 20rpx;
			width: 670rpx;
			height: 248rpx;
			background: #342857;
			border-radius: 12rpx 12rpx 12rpx 12rpx;
			font-weight: 400;
			font-size: 32rpx;
			padding: 20rpx;
			color: #FFF;
			position: relative;
			.btn_change{
				width: 130rpx;
				height: 52rpx;
				background: linear-gradient( 274deg, #0014FF 0%, #8020EF 50%, #FF2CDF 100%);
				border-radius: 96rpx 96rpx 96rpx 96rpx;
				font-weight: 400;
				font-size: 28rpx;
				color: #FFFFFF;
				text-align: center;
				line-height: 52rpx;
				position: absolute;
				right: 24rpx;
				bottom: 14rpx;
			}
		}

		>input {
			margin: 0 auto;
			margin-top: 40rpx;
			width: 670rpx;
			height: 96rpx;
			line-height: 96rpx;
			font-weight: 300;
			font-size: 30rpx;
			color: #A6A5AF;
			background: #342857;
			padding-left: 20rpx;
			border-radius: 12rpx 12rpx 12rpx 12rpx;
		}
	}

	.binding {
		width: 90%;
		margin: 0 auto;
		padding: 18rpx 0;
		border-radius: 60rpx;
		// background: #2B2749;
		/* border-bottom: 1rpx solid #5a5a5a70; */
	}

	/deep/.u-button--success {
		background: none !important;
		border: none !important;
		color: #FF2CDF !important;
	}

	/deep/.u-border {
		width: 670rpx;
		height: 96rpx;
		background: #342857;
		border-radius: 12rpx 12rpx 12rpx 12rpx;
		border: none;
		// border-bottom: 2rpx solid rgba(255, 44, 223, 0.5) !important;
	}

	/deep/.uni-input-wrapper {
		color: #A6A5AF !important;
	}

	/deep/.uni-input-placeholder {
		color: #A6A5AF !important;
	}
	/deep/.uni-input-input{
		color: #FFFFFF;
			font-weight: 300;
			font-size: 30rpx;
	}
	.btn {
		width: 690rpx;
		height: 88rpx;
		background: linear-gradient(274deg, #0014FF 0%, #8020EF 50%, #FF2CDF 100%);
		border-radius: 332rpx 332rpx 332rpx 332rpx;
		margin: 0 auto;
		margin-top: 50rpx;
		font-weight: 400;
		font-size: 36rpx;
		color: #FFFFFF;
		text-align: center;
		line-height: 88rpx;
	}

	.tip {
		width: 670rpx;
		height: 52rpx;
		font-family: Alibaba PuHuiTi 2.0, Alibaba PuHuiTi 20;
		font-weight: 400;
		font-size: 24rpx;
		color: #FF2CDF;
		margin: 0 auto;
		margin-top: 40rpx;
	}
</style>